import os
import pytest
from utils.login import login
import logging

def pytest_addoption(parser):
    parser.addoption("--env",
                     action="store",
                     dest="environment",
                     default="test",
                     help="environment: test or dev")

@pytest.fixture(scope="session")
def env(request):
    config_path = os.path.join(request.config.rootdir,
                               "env",
                               request.config.getoption("environment"),
                               "config.py")
    return config_path

# @pytest.fixture(scope="class", autouse=True)
# def page():
#     global playwright, browser
#     playwright = sync_playwright().start()
#     browser = playwright.chromium.launch(headless=True, args=["--start-maximized"])
#     context = browser.new_context(ignore_https_errors=True, no_viewport=True)
#     page = context.new_page()
#     page = login(page)
#     return page
#
# @pytest.fixture(scope="class", autouse=True)
# def quit_browser():
#     yield playwright
#     browser.close()
#     playwright.stop()
# @pytest.fixture(scope="session", autouse=True)
# def set_logging():
#     logger = logging.getLogger(__name__)
#     logging.basicConfig(level=logging.INFO)
#     logger.info("Logging started")
#     logger.setLevel(level=logging.INFO)
    # yield

@pytest.fixture(scope="session", autouse=True)
def get_auth():
    login()